package com.wj.springboot2demo.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.wj.springboot2demo.FeignService;

@RestController
public class CloudConsulController {

    @Autowired
    private DiscoveryClient discoveryClient;

    /**
     * 获取所有服务
     */
    @RequestMapping("/services")
    public Object services() {
        return discoveryClient.getServices();
    }
    @RequestMapping("/services/list")
    public Object servicesList() {
        return discoveryClient.getInstances("test-springcloud");
    }
    
    @Autowired
    private FeignService feignService;

    @RequestMapping(value = "/feign/mysql", method = RequestMethod.GET)
    public Object consumerCloud() {
        
        return feignService.hello("testcloud");
    }

    @RequestMapping("/home")
    public String home() {
        return "Hello World";
    }
}
